package cn.libinal.scloud.base.oauth.controller;

import cn.libinal.scloud.base.common.web.ResultJson;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * scloud
 *
 * @author lbb created by 2019/1/23 15:00
 */
@RestController
public class LogoutController {
    private final ConsumerTokenServices consumerTokenServices;

    public LogoutController(ConsumerTokenServices consumerTokenServices) {
        this.consumerTokenServices = consumerTokenServices;
    }

    @DeleteMapping(value = "/exit")
    public ResultJson revokeToken(String access_token){
        if (consumerTokenServices.revokeToken(access_token)){
            return ResultJson.success("注销成功");
        }else {
            return ResultJson.success("注销失败");
        }
    }
}
